<template>
  <!-- 阅读协议页 -->
  <div class="readDeal">
    <div class="btn_read">
      <u--text text="欢迎您使用“都高人”!" color="#000"></u--text>
      <div style="margin-top: 10px">
        <button
          class="btn"
          type="primary"
          @click="isRead"
          style="background: #1990ff; font-size: 16px; border-radius: 10px"
        >
          已阅读
        </button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      id: 1,
    };
  },
  onLoad: function (option) {
    //option为object类型，会序列化上个页面传递的参数
    // console.log(option);
    this.id = option.flag;
  },
  methods: {
    //点击已阅读
    isRead() {
      var pages = getCurrentPages();
      var prevPage = pages[pages.length - 2];
      if (this.id) {
        uni.showToast({
          title: "已阅读",
          duration: 2000,
          success: () => {
            setTimeout(() => {
              this.id = 0;
              prevPage.setData({
                data1: this.id,
              });
              uni.navigateBack({
                delete: 1,
              });
            }, 600);
          },
        });
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.readDeal {
  padding: 15px 15px;
}
</style>